<?php
if(!defined('ADMINPX') || !defined('ADMIN')) {
	exit('Access Denied');
}
$act=$_GET['act'];
$id=$_GET['id'];
$fid=$_GET['fid'];
$aa=$_GET['aa'];
if($act=='tzhf'){
    	    if($db->update('forum',array('sz_sc' => 0)," `id`= '$id'")){
	           echo"恢复帖子成功<br/>";
          }else{
		         echo"恢复帖子失败<br/>";
          }
          echo "正在自动返回.......<br/><a href=\"admin.php?action=forum_hs\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=forum_hs'>";
}else if($act=='xgtz'){
echo <<<end
<div class="admin">查看帖子<br/></div>
end;
$row=$db->get_one('forum'," `id` ='$id'",'');
$row[content]=$ubb->content_ubb($row[content]);
$namee=$user_class->user_name($row[uid]);
echo <<<end
<div class="admin_a">会员：<a href="user-$row[uid].html">$namee</a></div>
<div class="admin_a">标题：$row[name] <br/></div>
<div class="admin_a">内容：$row[content] <br/></div>
<a href="admin.php?action=forum_hs&act=tzhf&id=$row[id]&fid=$fid">恢复帖子</a><br/>
<a href="admin.php?action=forum_hs&act=sctzts&id=$row[id]&fid=$fid">删除帖子</a><br/>
end;
}else if($act=='sctzts'){
	 echo"注意：删除帖子所有数据！<br/>";
   echo "<a href=\"admin.php?action=forum_hs&act=sctz&id=$id\">确定切底删除</a><br/>";
}else if($act=='sctz'){
	$sql=$db->query('forum_data'," `fid` ='$id'ORDER BY `id` ","");
	while($row=mysql_fetch_array($sql)){
       @unlink (Bingz_upload_images('data/forum/'.$row[url].''));
       @unlink ("data/forum/".$row[url]."");
   	   $db->delete('forum_data'," `id` = '$row[id]'");
		   $db->delete('forum_data_user'," `fid` = '$row[id]'");
  }
   	   $db->delete('forum_hui'," `fid` = '$id'");
   	   $db->delete('forum'," `id` = '$id'");
	 echo "删除成功<br/>";
   echo "正在自动返回.......<br/><a href=\"admin.php?action=forum_hs&\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=forum_hs&'>";
}else if($act=='scqbtzts'){
	 echo"注意：清空回收站删除回收所有帖子！<br/>";
   echo "<a href=\"admin.php?action=forum_hs&act=scqbtz\">确定清空回收站</a><br/>";
}else if($act=='scqbtz'){
  $sqlb=$db->query('forum'," `sz_sc` ='1'",'');
	$aa='0';
  while($rowa=mysql_fetch_array($sqlb)){
	    $sql=$db->query('forum_data'," `fid` ='$rowa[id]'ORDER BY `id` ","");
	    while($row=mysql_fetch_array($sql)){
         @unlink (Bingz_upload_images('data/forum/'.$row[url].''));
         @unlink ("data/forum/".$row[url]."");
   	     $db->delete('forum_data'," `id` = '$row[id]'");
		     $db->delete('forum_data_user'," `fid` = '$row[id]'");
      }
   	   $db->delete('forum_hui'," `fid` = '$rowa[id]'");
   	   $db->delete('forum'," `id` = '$rowa[id]'");
       $aa++;
  }
	echo "清空回收站成功<br/>删除帖子：$aa<br/>";
  echo "正在自动返回.......<br/><a href=\"admin.php?action=forum_hs&\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=forum_hs&'>";
}else if($act=='lttz'){
echo <<<end
<div class="admin">论坛帖子回收站<br/></div>
end;
	if($_POST[lt]){
   $num_count=$db->num_rows('forum'," `sz_sc` ='1' AND `cid` ='$_POST[lt]'",'id');
   $list_num ="10";
   $num_start=page_num($list_num,$num_count);
   $sql_bbs  =$db->query('forum'," `sz_sc` ='1'  AND `cid` ='$_POST[lt]' ORDER BY `id` DESC LIMIT ".$num_start." , ".$list_num." ",'');
 	}else{
   $num_count=$db->num_rows('forum'," `sz_sc` ='1' ",'id');
   $list_num ="10";
   $num_start=page_num($list_num,$num_count);
   $sql_bbs  =$db->query('forum'," `sz_sc` ='1' ORDER BY `id` DESC LIMIT ".$num_start." , ".$list_num." ",'');
  }
   $a=$row_start+1;
  while($row_c=@mysql_fetch_array($sql_bbs)){
echo <<<end
<div class="admin_a">$a 、$row_c[name]
[<a href="admin.php?action=forum_hs&act=xgtz&id=$row_c[id]&fid=$fid">查看</a>
/ <a href="admin.php?action=forum_hs&act=tzhf&id=$row_c[id]&fid=$fid">恢复</a>
/ <a href="admin.php?action=forum_hs&act=sctzts&id=$row_c[id]&fid=$fid">删除</a>]<br/></div>
end;
    $a++;
  }
   echo $page=page_link($list_num,$num_count);

}else if($act =='qtzsc'){
         if($_POST['delete']){
            foreach($_POST['delete'] as $id ){
	$sql=$db->query('forum_data'," `fid` ='$id'ORDER BY `id` ","");
	while($row=mysql_fetch_array($sql)){
       @unlink (Bingz_upload_images('data/forum/'.$row[url].''));
       @unlink ("data/forum/".$row[url]."");
   	   $db->delete('forum_data'," `id` = '$row[id]'");
		   $db->delete('forum_data_user'," `fid` = '$row[id]'");
  }
   	   $db->delete('forum_hui'," `fid` = '$id'");
   	   $db->delete('forum'," `id` = '$id'");
            }
         }
	       echo "提交成功<br/>";	
         echo "正在自动返回.......<br/><a href=\"admin.php?action=forum_hs\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=forum_hs&'>";
}else{
echo '<div class="admin">帖子回收站<br/></div>
<form method="POST" action="admin.php?action=forum_hs&act=lttz" >
选择论坛：<select name="lt">';
	$sql=$db->query('forum_class',"1 ORDER BY `id` ","");
	while($row=mysql_fetch_array($sql)){
echo <<<end
<option value="$row[id]">$row[name]</option>
end;
}
echo <<<end
</select>
<input type="submit" value="进入" name="b1" />
</form>
<div class="admin">最新回收帖<br/></div>
<form method="POST" action="admin.php?action=forum_hs&act=qtzsc" >
end;

   $num_count=$db->num_rows('forum'," `sz_sc` ='1' ",'id');
   $list_num ="10";
   $num_start=page_num($list_num,$num_count);
   $sql_bbs  =$db->query('forum'," `sz_sc` ='1' ORDER BY `id` DESC LIMIT ".$num_start." , ".$list_num." ",'');
   $a        =$num_start+'1';
   while($row_c=mysql_fetch_array($sql_bbs)){
$namep='name="delete[]" value="'.$row_c[id].'"';
echo <<<end
<div class="admin_a">$a 、<input class="checkbox" type="checkbox" $namep />
$row_c[name]
[<a href="admin.php?action=forum_hs&act=xgtz&id=$row_c[id]&fid=$fid">查看</a>
/ <a href="admin.php?action=forum_hs&act=tzhf&id=$row_c[id]&fid=$fid">恢复</a>
/ <a href="admin.php?action=forum_hs&act=sctzts&id=$row_c[id]&fid=$fid">删除</a>]<br/></div>
end;
      $a++;
   }
   echo '
<input type="checkbox" name="chkall" id="chkallpqwy" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'delete\')" />全部删除?
<input type="submit" value="提交" name="adminpost" />
</form>
   <div class="bzqczy"></div>'.$page=page_link($list_num,$num_count);
}
echo "<a href=\"admin.php?action=forum_hs&act=scqbtzts&fid=$fid\">清空回收站</a><br/>";
echo "<a href=\"admin.php?action=forum_hs&\">返回回收站</a><br/>";
?>